﻿@using DMS.BO.Security.Principal
@using DMS.BO.Web.Ajax
@model dynamic

@{
    ViewBag.Title = "Danh sách sản phẩm";
}

<div id="left">
    @using (Ajax.BeginForm("Search", "Product", FormMethod.Post, new BOAjaxOptions { UpdateTargetId = "ProductSearchResult" }, new { @id = "frmProduct" }))
    {
        <div class="box" style="margin-left: 10px; margin-top: 35px;">
            <div class="control-group">
                <b>TÌM KIẾM</b>
            </div>
            <div class="control-group">
                <div>
                    Mã sản phẩm
                   
                   <input type="text" name='ID' class='input-medium' data-rule-required="true" data-rule-email="true">
                </div>
            </div>
            <div class="control-group">
                <div>
                    Tên sản phẩm
                   
                   <input type="text" name="Name" class='input-medium' data-rule-required="true">
                </div>
            </div>

            <div class="submit">
                <input type="submit" id="btnSearch" value="Tìm kiếm" class='btn btn-primary'>
            </div>
        </div>
       
        <input type="hidden" id="PageIndex" name="PageIndex" value="1" />
        <input type="hidden" id="PageSize" name="PageSize" value="10" />
    }

</div>
<div id="main">
    <div class="container-fluid">
        <div class="page-header">
            <div class="pull-left">
                <h1>Danh sách sản phẩm</h1>
            </div>
            <div class="pull-right">
            </div>
        </div>
        <div class="breadcrumbs">
            <ul>
                <li>
                    <a href="/Home">Trang chủ</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li>
                    <a href="#">Danh sách sản phẩm</a>
                </li>
            </ul>
            <div class="close-bread">
                <a href="#"><i class="icon-remove"></i></a>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div style="margin-bottom: 10px; margin-top: 10px;">
                        @if (PermissionUtility.HasPermission(DMSPermission.SanPham_ThemMoi))
                        {
                            <input type="button" id="btnAddProduct" value="Thêm mới" class='btn btn-primary' />
                        }
                    </div>
                    <div id="ProductSearchResult" class="box-content nopadding">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="divDialog">
    <div id="dialogContent">
    </div>
</div>

<script type="text/javascript">
    function openDialog() {
        dialog = $('#divDialog').dialog({
            autoOpen: true,
            width: 600,
            modal: true,
            title: "Thông tin sản phẩm"
        });
    };

    function closeDialog() {
        $('#divDialog').dialog("close");
    };

    $("#btnAddProduct").live("click", function () {
        $.get("Product/Add", function (result) {
            $('#dialogContent').html(result);
            openDialog();
        });
    });

    $("#btnSearch").live("click", function () {
        $("#PageIndex").val("1");
    });
</script>
